import { textInfo } from "../util/play.js"

export function compareTEXT(data){
var arr = textInfo()
  for(var i = 0;i < arr.length;i++){
        var j = comapreString(data,arr[i][0])
        if(j>70){
            console.log("相似度匹配成功")
            return arr[i][1]
        }
        
  }
  return "我不知道你在说什么"

}


 export function comapreString(t1,t2){

    var x = t1.split('')
    var y = t2.split('')

    var z = 0;
	var s = x.length + y.length;;
	x.sort();
	y.sort();
	var a = x.shift();
	var b = y.shift();

	while(a !== undefined && b !== undefined) {
		if (a === b) {
			z++;
			a = x.shift();
			b = y.shift();
		} else if (a < b) {
			a = x.shift();
		} else if (a > b) {
			b = y.shift();
		}
	}
	return z/s * 200;
}
